package com.galeno.zoopeeper;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/7/319:08
 */
public class DemoWatch {
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    //
    ZooKeeper zk= new ZooKeeper(
        "galeno01:2181",
        1000,
        new Watcher() {
          @Override
          // 连接成功  监控通知  调用process方法
          public void process(WatchedEvent event) {
              System.out.println("连接成功");
          }
        });
    zk.getChildren("/",null);
    Thread.sleep(Long.MAX_VALUE);
  }


}
